<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我的学员</title>
<link rel="stylesheet" type="text/css"
	href="/bootstrap/bootstrap.4.1.0.css">
<script src="/bootstrap/jquery.3.2.1.min.js"></script>
<script src="/bootstrap/popper.12.5.min.js"></script>
<script src="/bootstrap/bootstrap.4.1.0.min.js"></script>
<script src="/layui/layer/layer.js"></script>
<script src="/vue/Vue.js"></script>
<script src="/vue/axios.js"></script>
<style type="text/css">
.active {
	background-color: blue;
}
</style>
<script type="text/javascript">
	$(function() {
		$("#header").load("header.html");
		
	})
</script>
</head>
<body>
	<div id="header"></div>
	<div id="all" class="container">
		<div v-if="users!=null">
				<table class="table table-striped table-hover text-center">
				<thead>
					<tr>
						<th>序号</th>
						<th>头像</th>
						<th>昵称</th>
						<th>角色</th>
						<th>微信</th>
						<th>qq</th>
						<th>电话</th>
						<th>描述</th>
					</tr>
				</thead>
				<tbody>
					<tr v-for="(user,index) in users" :key="index">
						<td>{{index+1}}</td>
						<td><img alt="" :src="user.avatar" class="rounded-circle" style="width:35px;height:35px"></td>
						<td><a href="javascript:;" @click="moreinfo(user)">{{user.nickname}}</a></td>
						<td>{{user.role}}</td>
						<td>{{user.wechat}}</td>
						<td>{{user.qq}}</td>
						<td>{{user.phone}}</td>
						<td>{{user.description}}</td>
					</tr>
				</tbody>
			</table>
			</table>
			<div class="row">
				<div class="offset-md-5">
					<ul class="pagination">
						<li class="page-item"><a class="page-link" href="#"
							@click.prevent="prePage"> <</a></li>
						<li class="page-item" v-for="(item, index) in pageNum"><a
							class="page-link" href="#" v-on:click.prevent="getFriends(item)"
							:class="{active: currentPage==index+1}">{{ index+1 }}</a></li>
						<li class="page-item"><a class="page-link" href="#"
							v-on:click.prevent="nextPage">></a></li>
					</ul>
				</div>
			</div>
		</div>
		<div v-else class="row">
			<p class="offset-md-5">还没有关注您的人哟!</p>
		</div>
	</div>
</body>
<script type="text/javascript">
	new Vue({
		el:"#all",
		data:{
			users:[],
			pageNum:0,
			currentPage:0,
		},
		mounted(){
			this.getUsers(1);
		},
		methods:{
			getUsers:function(page){
				axios.get("/focus/focusMe?page="+page)
				.then(
					res => {
						if(res.data.code==1){
							this.users = res.data.data.list;
							this.currentPage = res.data.data.nowPage;
							this.pageNum = res.data.data.totalPage;
						}else{
							layer.alert("服务器忙，请稍后再试");
						}
					}
				
				)
			},
			prePage:function(){
				if(this.currentPage>1){
					this.getUnread(this.currentPage-1);
				}
			},
			nextPage:function(){
				if(this.currentPage<this.pageNum){
					this.getUnread(this.currentPage+1);
				}
			},
			moreinfo:function(user){
				console.log(user.role);
				if(user.role=="student"){
					location.href = "/lsw/student_view.html?id="+user.id;
				}else if(user.role=="coach"){
					location.href = "/lsw/coach_view.html?id="+user.id;
				}else if(user.role=="gym"){
					location.href = "/lsw/gym_view.html?id="+user.id;
				}
			}
		}
	})
</script>
</html>